// 防抖，只执行操作的最后一次
function debounce(fn, time, immdate) {
    let timer = null
    return function(...args) {
        if (timer) {
            clearTimeout(timer)
            timer = null
        } else if (immdate) {
            fn.apply(this, args)
        }
        timer = setTimeout(() => {
            fn.apply(this, args)
            timer = null
        }, time)
    }
}